<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    .content {
      width: 400px;
      height: 400px;
      border: 1px solid #eee;
      border-radius: 6px;
      box-shadow: 5px 5px 5px #ccc;
    }
    button {
      width: 60px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      background-color: #56a5f1;
      color: white;
      border: 1px solid #eee;
      border-radius: 6px;
      outline: none;
    }
    .mask {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(1,1,1,0.6);
    }
    .loading {
      position: absolute;
      top: 100px;
      margin-left: 50%;
      left: -50px;
      width: 0px;
      height: 0px;
      border-top: 40px solid red;
      border-right: 40px solid pink;
      border-bottom: 40px solid greenyellow;
      border-left: 40px solid orange;
      border-radius: 50%;
    }
    .triangle {
      display: inline-block;
      width: 0px;
      height: 0px;
      border-top: 50px solid transparent;
      border-right: 50px solid transparent;
      border-bottom: 50px solid transparent;
      border-left: 50px solid red;
      transform: rotate(30deg);
    }
  </style>
  <title>Document</title>
</head>
<body>
  <label for="">音乐ID:</label>
  <input type="text" placeholder="请输入id" class="id" value="28012031">
  <p>
    <label for="">请选择查看类型：</label>
    <label for="song">歌曲</label>
    <input type="radio" name="type" id="song" value="song">
    <label for="lyric">歌词</label>
    <input type="radio" name="type" id="lyric" value="lyric">
    <label for="comments">评论</label>
    <input type="radio" name="type" id="comments" value="comments">
    <label for="detail">详情</label>
    <input type="radio" name="type" id="detail" value="detail">
  </p>
  <br>
  <button class="btn">搜索</button>
  <div class="triangle"></div>
  <p class="content"></p>
  <div class="mask">
    <div class="loading"></div>
  </div>
  <script src="./js/jquery-3.3.1.min.js"></script>
  <script>
    $(function() {

      $('.btn').click(function() {
        $('.mask').toggle()
        var id = $('.id').val();
        var type = $('input[type=radio]:checked').val();
        let url = `https://api.imjad.cn/cloudmusic/`;
        $.ajax({
          // url: `https://api.imjad.cn/cloudmusic/?type=${type}&id=${id}&br=128000`,
          url,
          method: 'GET',
          data: {
            type: type,
            id,
            br: '128000'
          },
          success: function(result) {
            $('.mask').toggle()
            console.log(result)
            let text = ''
            if(type == 'song') {
              text = `<a href=${result.data[0].url} target=_blank>点击试听</a>`
            }else if(type == 'lyric') {
              text = ''
            }else if(type == 'comments') {
              text = ''
            }else if(type == 'detail') {
              text = `<img width=350 height=350 src=${result.songs[0].al.picUrl}>`;
            } 
            $('.content').html(text)
          }
        })
      })

    })
  </script>
</body>
</html>